/* 
 * File:   ScalarDataset.cpp
 * Author: cjjonker
 *
 * Created on 20 december 2012, 18:17
 */

#include "ScalarDataset.h"
#include <limits>

using namespace std;

ScalarDataset::ScalarDataset()
{ 
}

ScalarDataset::ScalarDataset(double** dat, int dim, int b)
{
    d_data = dat;
    d_buffersize = b;
    d_dim = dim;
}

double ScalarDataset::getMin(int t_depth, int slice_dt) 
{
    double retMin = numeric_limits<double>::max();
    for (int t = 0; t != t_depth*slice_dt; t+=slice_dt)
    {
        for (int idx = 0; idx != d_dim * d_dim; ++idx)
                retMin = min(retMin, this->getData(idx, t));
    }
    return retMin;
}

double ScalarDataset::getMax(int t_depth, int slice_dt)
{
    
    double retMax = numeric_limits<double>::min();
    for (int t = 0; t != t_depth*slice_dt; t+=slice_dt)
        for (int idx = 0; idx != d_dim * d_dim; ++idx)
                retMax = max(retMax, this->getData(idx, t));
    return retMax;
}


void ScalarDataset::calcMin() 
{
    calcMin(1,1);
}

void ScalarDataset::calcMax()
{
    calcMax(1,1);
}

void ScalarDataset::calcMin(int t_depth, int slice_dt) 
{ 
    d_min = getMin(t_depth, slice_dt); 
}

void ScalarDataset::calcMax(int t_depth, int slice_dt) 
{ 
    d_max = getMax(t_depth, slice_dt); 
}
